package jp.sourceforge.akjrcp.psp;

import java.io.File;

public class PSPUtils {
public static final String DIR_PSP="VIDEO";
public static final String DIR_VIDEO="VIDEO";
public static final String DIR_PICTURE="PICTURE";
public static final String DIR_MUSIC="MUSIC";
	public static File findPSPDrive(){
		File roots[]=File.listRoots();
		for (int i = roots.length-1; i >0; i--) {
			File tmp=new File(roots[i],DIR_PSP);
		if(tmp.exists() && tmp.isDirectory()){
			return tmp.getParentFile();
			}
		}
		
		return null;
	}
	public static File findVideoFolder(){
		File root=findPSPDrive();
		if(root!=null){
			File dir=new File(root,DIR_VIDEO);
			if(dir.exists()){
				return dir;
			}
		}
		return null;
	}
	public static File findPictureFolder(){
		File root=findPSPDrive();
		if(root!=null){
			File dir=new File(root,DIR_PICTURE);
			if(dir.exists()){
				return dir;
			}
		}
		return null;
	}
	public static File findMusicFolder(){
		File root=findPSPDrive();
		if(root!=null){
			File dir=new File(root,DIR_MUSIC);
			if(dir.exists()){
				return dir;
			}
		}
		return null;
	}
	public static boolean existVideoFolder(File pspDrive){
		File videoFolder=new File(pspDrive,DIR_VIDEO);
		return videoFolder.exists();
	}
	
	public static boolean existPictureFolder(File pspDrive){
		File videoFolder=new File(pspDrive,DIR_PICTURE);
		return videoFolder.exists();
	}
	
	public static boolean existMusicFolder(File pspDrive){
		File videoFolder=new File(pspDrive,DIR_MUSIC);
		return videoFolder.exists();
	}
}
